package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.model.Member;
import com.yami.shop.bean.model.ShopMember;
import com.yami.shop.common.util.PageAdapter;
import com.yami.shop.dao.MemberMapper;
import com.yami.shop.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, ShopMember> implements MemberService {

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public IPage<ShopMember> pagebyMember(Page<ShopMember> page, ShopMember shopMember) {
        page.setRecords(memberMapper.pagebyMember(new PageAdapter(page),shopMember));
        page.setTotal(memberMapper.countMember(shopMember));
        return page;
    }

    @Override
    public void addShopMember(Member member) {
        memberMapper.addMember(member);
    }

    @Override
    public ShopMember getMember(Long memberId) {
        return memberMapper.getMember(memberId);
    }

    @Override
    public Member getRepeatMember(Member member) {
        return memberMapper.getRepeatMember(member);
    }

    @Override
    public void updateStatus(Long memberId) {
        memberMapper.updateStatus(memberId);
    }

    @Override
    public void restoreMember(Long memberId) {
        memberMapper.restoreMember(memberId);
    }
}
